﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace wordsMemory
{
    public partial class Form1 : Form {
        int i = 0;
        int max;
        List<Word> words = new List<Word>();
        WordService wordService=new WordService();
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox1.Text.Equals(words[i].English))
                {
                    MessageBox.Show("恭喜你答对啦！");
                    if (i < max - 1)
                    {
                        i++;
                        label3.Text = words[i].Chinese;
                    }

                    else
                    {
                        MessageBox.Show("恭喜你已完成全部拼写");
                    }
                       
                }
                else
                {
                    MessageBox.Show("答错了哦");
                }
            }catch (Exception ex)
            {
             
                MessageBox.Show(ex.Message, "错误");
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                words = wordService.GetWords();
                max = words.Count;
                label3.Text = words[0].Chinese;
            }
            catch (Exception ex)
            {
               
                MessageBox.Show(ex.Message, "错误");
            }
        }
    }
}
